package com.example.todolist;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class OlddetailActivity extends AppCompatActivity {
    public  static  final  String TAG="detail";
    TextView title;
    TextView detail;
    TextView date;
    TextView ddl;
    Integer id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_olddetail);
        //接受
        Intent intent = getIntent();
        String ItemTitle=intent.getStringExtra("title");
        String ItemDetail=intent.getStringExtra("detail");
        String ItemDate=intent.getStringExtra("date");
        String ItemId=intent.getStringExtra("id");
        id=Integer.parseInt(ItemId);

        Log.i(TAG,"detail:id="+id);

        DBManager dbManager = new DBManager(OlddetailActivity.this);
        ListItem listItem = new ListItem();
        listItem=dbManager.findById(id);
        String deadline=listItem.getDdl();

        Log.i(TAG,"detail:ItemTitle="+ItemTitle);
        Log.i(TAG,"detail:ItemDetail="+ItemDetail);
        Log.i(TAG,"detail:ddl="+deadline);

        title=findViewById(R.id.detail_title2);
        detail=findViewById(R.id.detail_detail2);
        date=findViewById(R.id.detail_date2);
        ddl=findViewById(R.id.old_date);

        title.setText(ItemTitle);
        detail.setText(ItemDetail);
        date.setText(ItemDate);
        ddl.setText(deadline);
    }
}